# -*- coding: utf-8 -*-

from openerp import fields, models, api

class stock_quant_tree(models.Model):
    _inherit = 'stock.quant'

    product_uos_mmm=fields.Float(store=True,compute='_compute_product_uos_mmm')
    # product_uos_out_qty = fields.Float(store=True,compute='_compute_product_uos_out_qty')
    # product_uos_in_qty = fields.Float(store=True,compute='_compute_product_uos_in_qty')
    # product_uos_previous_qty= fields.Float(store=True,compute='_compute_product_previous_out_qty')
    # product_uos_current_qty= fields.Float(store=True,compute='_compute_product_uos_current_qty')
    attribute_1= fields.Many2one('product.attribute.value', string=u'属性1',store=True, 
        related="product_id.attribute_1")
    attribute_2= fields.Many2one('product.attribute.value', string=u'属性2',store=True,
        related="product_id.attribute_2")
    attribute_3= fields.Many2one('product.attribute.value', string=u'属性3',store=True, 
        related="product_id.attribute_3")
    attribute_4= fields.Many2one('product.attribute.value', string=u'属性4',store=True,
        related="product_id.attribute_4")
    attribute_5= fields.Many2one('product.attribute.value', string=u'属性5',store=True, 
        related="product_id.attribute_5")

    @api.one
    @api.depends('product_id.uos_id')
    def _compute_product_uos_mmm(self):
        print(self.product_id.uos_id)
        self.product_id.uos_id._compute_mmm()
        self.product_uos_mmm= self.product_id.uos_id.mmm

    # @api.one
    # @api.depends('product_uom_out_qty')
    # def _compute_product_uos_out_qty(self):
    #     self.product_uos_out_qty = self.product_uom_out_qty / self.product_uos_mmm

    # @api.one
    # @api.depends('product_uom_in_qty')
    # def _compute_product_uos_in_qty(self):
    #     self.product_uos_in_qty = 1

    # @api.one
    # @api.depends('product_uom_previous_qty')
    # def _compute_product_uos_previous_qty(self):
    #     self.product_uos_previous_qty = self.product_uom_previous_qty / self.product_uos_mmm

    # @api.one
    # @api.depends('product_uom_current_qty')
    # def _compute_product_uos_current_qty(self):
    #     self.product_uos_current_qty = self.product_uom_current_qty / self.product_uos_mmm